//导入请求工具
import request from '@/utlis/request.js'

//提供调用接口的函数
//注册
export const registerService = (registerData)=>{
    //看接口文档要传递什么参数

    //使用URLSearchParams来解析参数
    // const params = new URLSearchParams()
    // for (let key in registerData) {
    //     params.append(key, registerData[key])
    // }

    // return request.post('/user/register', params)
    return request.post('/user/register', registerData)
}
//登录
export const loginService = (loginData) =>{
    const params = new URLSearchParams()
    for(let key in loginData){
        params.append(key, loginData[key])
    }
    return request.post('/user/login',params)
}
//获取个人信息
export const userInfoGetService = ()=>{
    return request.get('/user/userInfo');
}

//修改个人信息
export const userInfoUpdateService = (userInfo)=>{
    return request.put('/user/update',userInfo)
}

//修改头像
export const userAvatarUpdateService=(avatarUrl)=>{
    let params = new URLSearchParams();
    params.append('avatarUrl',avatarUrl)
    return request.patch('/user/updateAvatar',params)
}
//更新密码
export const userPasswordUpdateService=(userPassword)=>{
    return request.patch('/user/updatePwd',userPassword)
}